<template>
  <div class="xinDetail">
    <div class="xinDetail_header">
      <span @click="$router.go(-1)"><van-icon name="arrow-left" /></span>
      <p></p>
      <p></p>
    </div>
    <div class="xinDetail_main">
      <div class="main_img">
        <img :src="detailObj.img" alt="" />
      </div>
      <div class="main_house">
        <h3>{{ detailObj.shuoming }}</h3>
        <p>
          <span>{{ detailObj.jiage }}万</span>&emsp;
          <span>{{ detailObj.tingshi }}1厅1卫</span>&emsp;
          <span>{{ detailObj.pingmi }}m</span>
        </p>
      </div>
      <div class="main_list">
        <h3>推荐房源</h3>
        <dl v-for="v in resultsList" :key="v.id">
        <dt><img :src="v.img" alt="" /></dt>
        <dd>
          <h4>{{ v.name }}</h4>
          <p>
            <span>{{ v.tingshi }}</span>
          </p>
          <p>
            <span>{{ v.m2jiage }}</span>
            <span>{{ v.m2 }}万</span>
          </p>
          <p>
            {{ v.data }}
          </p>
        </dd>
      </dl>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "../axios/index";
export default {
  name: "XinDetail",
  data() {
    return {
      id: "",
      msg: "",
      three: "",
      detailObj: {},
      resultsList: []
    };
  },
  methods: {
    getDetailObj() {
      axios
        .get("/upload", {
          params: {
            id: this.id,
            msg: this.msg,
            three: this.three,
          },
        })
        .then((res) => {
          console.log(res);
          this.detailObj = res.post;
          this.resultsList = res.results;
          console.log(this.detailObj);
        });
    },
  },
  created() {
    if (window.localStorage.getItem("router") === "/xin") {
      this.msg = "";
      this.three = "";
      this.id = this.$route.params.id;
    }
    if (window.localStorage.getItem("router") === "/esf") {
      this.msg = this.$route.params.id;
      this.three = "";
      this.id = "";
    }
    if (window.localStorage.getItem("router") === "/chuz") {
      this.msg = "";
      this.three = this.$route.params.id;
      this.id = "";
    }
    this.getDetailObj();
  },
};
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
  list-style: none;
  box-sizing: border-box;
}
.xinDetail {
  width: 100%;
  height: 100%;
}
.main_house {
  padding: 0 10px;
  line-height: 45px;
}
.main_house p {
  color: red;
  font-size: 18px;
}
.main_list dl {
  width: 100%;
  height: auto;
  display: flex;
  /* padding: 5px 10px; */
}
.main_list dl dt {
  width: 150px;
  height: 100px;
  margin: 5px 0;
  margin-right: 10px;
}
.main_list dl dt img {
  width: 100%;
  height: 100%;
}
.main_list dl dd {
  font-size: 14px;
}
.main_list dl dd p:nth-child(3) span:first-child {
  margin-right: 5px;
  color: orange;
}
.main_list dl dd p:last-child {
  padding: 2px 8px;
  background: #eee;
  width: 60px;
  text-align: center;
}
.xinDetail_header {
  position: absolute;
  top: 5px;
  left: 0;
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  font-size: 20px;
}
.xinDetail_header span {
  width: 40px;
  height: 40px;
  text-align: center;
  line-height: 40px;
  color: #fff;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
}
.xinDetail_main {
  width: 100%;
  height: auto;
}
.xinDetail_main .main_img {
  width: 100%;
  height: 250px;
}
.xinDetail_main .main_img img {
  width: 100%;
  height: 100%;
}
</style>